Filter by
All Annotations
  • All Annotations 43
  • De4f5def6e43e9bf4eccdc4dd71cbe40 John Resig 40
  • Eeb7fcfe88c6ee1d8395004cf5d9bffb figital 1
  • 7ed564bb400f2ce15cbcacccea189c00 httpJunkie 1
  • D6a22346ee8719a9b2c99904f4e6ab43 kopiro 1

Sorry, we couldn't find where this annotation belongs on the page. But you can read it here:

Note: This may not be the first first code released, but it appears to be the earliest copy that we’ve found, so far. This is a copy that was indexed by the Internet Archive on Feb 3rd 2006, so about 2.5 weeks after the initial release. It’s very likely that a few things changed in that time period and I’ll try to make a note of some of those, that I can remember, inline.

This video is processing – it'll appear automatically when it's done.

Sorry, we couldn't find where this annotation belongs on the page. But you can read it here:

My post-mortem blog post where I announce what I released at BarCamp NYC:
John Resig - BarCampNYC Wrap-up

jQuery was just one of a couple projects that I had been working on! After the release at Barcamp I did a lot to try and promote the library, mostly on Digg and Delicious (which were the two top places for promoting links at that time).

jQuery - New Wave Javascript Archive
home " programming " jQuery - New Wave Javascript

https://previous.delicious.com/url/32b2c30383abf5f586d72c1bf6cccab1

You can read more about the history of jQuery here:
History | jQuery Foundation

This video is processing – it'll appear automatically when it's done.

Sorry, we couldn't find where this annotation belongs on the page. But you can read it here:

The first release of jQuery didn’t include any Ajax functionality! Truth-be-told I found that I really didn’t need a separate Ajax library for the projects I was working on and it wasn’t until I had gotten a number of requests from users that I then wrote a brand-new one and included it in jQuery. jQuery 1.0 had Ajax built-in natively.

This video is processing – it'll appear automatically when it's done.

Sorry, we couldn't find where this annotation belongs on the page. But you can read it here:

On initial release jQuery was broken up into a couple modules. One of those modules was the ‘FX’ module which allowed you to do all sorts of animations. This was a library that I had written as a fork/clone of the moo.fx library (which later went on to become MooTools).

moo.fx - the next small thing Archive
moo.fx, a superlightweight javascript effects library

You can see the original FX source in the Internet Archive:

https://web.archive.org/web/20060205022911/http://jquery.com/src/minifx/minifx-latest.js

jQuery was essentially birthed from three libraries that I had written: A JavaScript CSS selector library, a moo.fx-like animation library, and an easy-to-use addEvent/removeEvent implementation. I combined all of these together into a simple API that was largely inspired by Prototype and the Behaviour library and here we go – the rest is history, so to speak!

This video is processing – it'll appear automatically when it's done.

Sorry, we couldn't find where this annotation belongs on the page. But you can read it here:

This module contained a bunch of nice events functionality, virtually all of which was later integrated into jQuery core:

https://web.archive.org/web/20060205034528/http://jquery.com/src/event/event-latest.js

Probably the biggest item here is the initial implementation of the .ready() method – one of the early attempts to try and make truly-progressive JavaScript that dynamically updated the DOM after load. This was actually a pretty big thing that jQuery promoted as most libraries expected you to run after window.onload or insert yourself into the very bottom of the page and then running immediately. jQuery was different because it promoted using progressive layering – passing down a functional page and then once the DOM was ready going through and updating it with JavaScript.

Note that the initial ready implementation is quite poor. A lot of iteration was happening on this concept. You can see Dean Edwards' blog post on the subject here:

window.onload (again)

This video is processing – it'll appear automatically when it's done.

Sorry, we couldn't find where this annotation belongs on the page. But you can read it here:

I guess it took me a little bit to develop the now-preferred ‘jQuery’ capitalization! I originally called this library “JSelect” (for selecting elements out of the page, plus it started with JS, which was nice). However the domain name jselect.com wasn’t available, thus I had to find another name.

This video is processing – it'll appear automatically when it's done.

Sorry, we couldn't find where this annotation belongs on the page. But you can read it here:

Even though the domain was available there apparently was another project (a Java SQL library) named jQuery. They had owned this domain a while back but had let it lapse. I only found this out later after they contacted me to let me know about the name conflict! I felt bad, I had definitely wanted to avoid causing any confusion!

This video is processing – it'll appear automatically when it's done.

Sorry, we couldn't find where this annotation belongs on the page. But you can read it here:

The very first release of jQuery (and for the next few months of releases) was under a Creative Commons license. I had released tons of open source projects before this point but I hadn’t put a license on anything as no one had ever asked for one! (Probably says something about how many people used them, ha!) In retrospect a CC license is a poor choice for code and I switched to using an MIT license pretty soon after.

At one point I went back and looked at the open source projects that I had released before jQuery. I counted 75 projects before this one! Before jQuery my most famous works were: A browser bookmarklet for easily saving links to Delicious (called LazySheep), a tool for navigating Wikipedia edit history (with which I won 2nd place in a contest), and a mini-library for binding events to DOM elements (which won 1st place in a contest and will talk about later as it influenced jQuery!).

This video is processing – it'll appear automatically when it's done.

Sorry, we couldn't find where this annotation belongs on the page. But you can read it here:

The infamous ‘$’! This, along with a lot of the functionality in jQuery, is directly inspired by the Prototype JavaScript library. The library was bundled with Rails, which was super-hot in 2005, when I was developing this library, and I loved a lot of the techniques that they were promoting. I aspired to have jQuery be a drop-in library that you could use side-by-side with Prototype.

This video is processing – it'll appear automatically when it's done.

Sorry, we couldn't find where this annotation belongs on the page. But you can read it here:

just trying the genius tool. for a n00b looking at this code … what is a and c? (not the point of john’s annotations … just curious what else this could do diving in and out of “words”). also curious to see how the annotation “threads” are sorted.

This video is processing – it'll appear automatically when it's done.

Sorry, we couldn't find where this annotation belongs on the page. But you can read it here:

A concept that attempts to make future releases of a project not directly conflict with it’s previous versions otherwise known as a “Breaking Changes”.

This video is processing – it'll appear automatically when it's done.

Sorry, we couldn't find where this annotation belongs on the page. But you can read it here:

We start to see some of the Prototype-specific functionality. We also see where some of the functionality starts to crumble. I wanted to provide a better implementation of their ‘$(…)’ function (which, by default, took a string and returned a DOM element that had that ID). I wanted to make ‘$(…)’ be able to handle that case AND be able to take both CSS and XPath selectors, too! You can start to see where this abstraction crumbles down as sometimes you’ll get a DOM element and sometimes you’ll get a jQuery object.

Additionally you get the weird edge case where if you have ‘$(“body”)’ – what is supposed to be returned? The body element? The element with an ID of body? Yeah, this wasn’t a great idea and it was gone before 1.0 was released.

This video is processing – it'll appear automatically when it's done.

Sorry, we couldn't find where this annotation belongs on the page. But you can read it here:

A major blunder. Instead of just making a jQuery function that was instantiated (and thus inherited its prototype) I instead made a new object every time with the relevant properties stuck in. This was corrected pretty soon after, I believe before 1.0 was released.

This video is processing – it'll appear automatically when it's done.

Sorry, we couldn't find where this annotation belongs on the page. But you can read it here:

So this may look crazy – it certainly does to me! Why not just do: f.call(this._get(i))? If I remember correctly, and I just did some double-checking and I think this is the case, but IE 5 didn’t support .call()! The original version of jQuery event worked back to IE 5… I can hardly believe. I think we ended up dropping support for IE 5 pretty soon after and “upgraded” to IE 6, which made stuff like this obsolete.

This video is processing – it'll appear automatically when it's done.

Sorry, we couldn't find where this annotation belongs on the page. But you can read it here:

This was later re-named into ‘.attr()’, since having another method named .get() (which gave you a DOM element) didn’t really make sense.

This video is processing – it'll appear automatically when it's done.

Sorry, we couldn't find where this annotation belongs on the page. But you can read it here:

So this is almost certainly not the first first release of the library as there are already deprecated methods. Deprecated after two weeks! Code moves so quickly :)

This video is processing – it'll appear automatically when it's done.

Sorry, we couldn't find where this annotation belongs on the page. But you can read it here:

I want to just take a moment to note how little has changed in how these functions work, at an API level. There’s a strong chance that you could take circa-2006 jQuery-using code and drop in a modern version and have it still work. Granted much more was added later on, as it increased in scope beyond my simple use cases, but almost all of the API that we see here was left intact. I’m definitely proud of the fact that the API was “good enough” to last over the next decade – and beyond.

Now, granted, there are a lot of things I would have loved to change about the API and as time went on it became harder, and harder, to do so (we desperately wanted to avoid breaking backwards compatibility). Regardless, we’re here now and as we can tell from the stats it seems to have been good enough!

This video is processing – it'll appear automatically when it's done.

Sorry, we couldn't find where this annotation belongs on the page. But you can read it here:

I really dis-liked having unnecessary braces. This… unfortunate… style preference plagued us for quite a while and caused all sorts of avoidable logic errors.

This video is processing – it'll appear automatically when it's done.

Sorry, we couldn't find where this annotation belongs on the page. But you can read it here:

Whoops! Assuming that everything was going to be a block was a mistake that we had to rectify later. Unfortunately ‘fixing’ this ended up being a lot harder than we expected! If you have some CSS that’s like “.foo { display: inline }” and you have a <div class="foo"></div> the only way you can figure out how it should become “visible” is to insert another div with that class and try to figure out what it’s final state should become. In general show/hide is a great convenience but it’s also a huge case for slow-downs and edge cases. We generally recommend toggling class names now instead.

This video is processing – it'll appear automatically when it's done.

Sorry, we couldn't find where this annotation belongs on the page. But you can read it here:

I’ve always been fond of the .wrap() method. It’s one of those things that’s a real pain to write from scratch but is super-convenient to have as a single method. This definitely is a key part of the “progressive enhancement” aspect that jQuery really embraced. Take an existing page and mark it up once you have JS running. Starting with something that works and make it even better if your browser supports it.

This video is processing – it'll appear automatically when it's done.

Sorry, we couldn't find where this annotation belongs on the page. But you can read it here:

Note that these methods are calling two global methods ‘addEvent’ and ‘removeEvent’ – we’ll get to that later.

This video is processing – it'll appear automatically when it's done.

Sorry, we couldn't find where this annotation belongs on the page. But you can read it here:

jQuery had proper method chaining from the very beginning. This was something that I was very passionate about as it allowed you to write some very terse code. It even included new conventions like .end() which allowed you to “pop” off of the chain stack.

I honestly can’t remember if I had seem examples of chaining before I wrote this in to jQuery. I know that I was writing a lot of Perl at the time, which has a lot of mechanisms for manipulating arrays (map, grep, etc.). I suspect that that’s what I was most influenced by – but I can’t be 100% sure! The chaining in jQuery has gone on to influence a large number of other libraries, even in other languages, which is pretty cool.

This video is processing – it'll appear automatically when it's done.

Sorry, we couldn't find where this annotation belongs on the page. But you can read it here:

All of the $.fn plugin methods are introduced here. This got a lot simpler once we starting using $.prototype as the base point for making plugin extensions. I discuss this a bit more below. Look for the line $.fn = {};

This video is processing – it'll appear automatically when it's done.

Sorry, we couldn't find where this annotation belongs on the page. But you can read it here:

This was a really-cool piece of functionality that I had in jQuery from day 1: the ability to take a HTML fragment and get back a jQuery collection with those DOM nodes in it. This has proved to be incredibly convenient and useful and is still being used today!

For this functionality it existed in an external function (named $C – which more closely matches some of the Prototype-isms of the type). Eventually this moved into the $(…) function call directly, where we looked for usage of < … > and then converted that into DOM elements. In retrospect this functionality probably better existed as an external function, to avoid ambiguities with CSS selectors.

This video is processing – it'll appear automatically when it's done.

Sorry, we couldn't find where this annotation belongs on the page. But you can read it here:

The HTML string cleaning logic here is actually very similar to what’s in $C(…) above – I’m surprised these weren’t combined into a single function. They definitely were at a later time, though!

This video is processing – it'll appear automatically when it's done.

Sorry, we couldn't find where this annotation belongs on the page. But you can read it here:

I had completely forgotten about these. I think I was trying to be cute and support something like: .append(“<div#id.class>”), to make the syntax even shorter. The fact that it’s commented out probably indicates how I thought about it at the time – it never did become integrated into jQuery.

This video is processing – it'll appear automatically when it's done.

Sorry, we couldn't find where this annotation belongs on the page. But you can read it here:

CSS selectors! Having the bulk of the functionality be contained in this one object was definitely very cute – perhaps too cute. You’ll note that they’re all strings and that below those strings are pushed into an eval() call. I think I was mostly going this route to try and save space, but this came at the expense of run-time costs, which is never a good idea. We changed this to just be normal function calls later.

This video is processing – it'll appear automatically when it's done.

Sorry, we couldn't find where this annotation belongs on the page. But you can read it here:

Was definitely influenced by XPath when including these custom selectors. Being able to manipulate and sub-select elements in the query results was quite useful!

This video is processing – it'll appear automatically when it's done.

Sorry, we couldn't find where this annotation belongs on the page. But you can read it here:

I always loved the :visible and :hidden selectors. Being able to quickly find elements that based upon their visibility is so useful. However it’s really come to haunt us as these are some custom CSS selectors that people still use, preventing us from just switching over to using the browser’s native querySelectorAll method wholesale. Oh well…

This video is processing – it'll appear automatically when it's done.

Sorry, we couldn't find where this annotation belongs on the page. But you can read it here:

Ahh – time for some CSS Selectors-in-JavaScript history! Thankfully Paul Irish wrote up a post charting some of these initial releases:
Javascript CSS Selector Engine Timeline

I was hugely inspired by Ben Nolan’s Behaviour library when working on jQuery. I wanted to make it super-easy to bind events to elements in the page, reducing the syntax required for Behaviour even more!

Archived version of the Behaviour library:
Behaviour : Using CSS selectors to apply Javascript behaviours

Behaviour used Simon Willison’s getElementsBySelector mini-library, which I was also inspired by. My selector engine implementation was directly inspired by his work. I wanted the library to be even more comprehensive, covering nearly all of the important CSS selectors, while also supporting XPath selectors(!!! More on that in a moment…)

I must’ve been made aware of Dean Edwards' cssQuery library some time before I released jQuery, however by that point I had already written my own engine. If memory serves me correctly Dean’s cssQuery was larger than the entirety of jQuery and I was really concerned about file size, so I opted not to switch over to it.

There was a lot of competition in the space. Behaviour + Prototype was popular and four days after I released jQuery Prototype introduced a native “$$(…)” method which took a CSS selector and returned a collection of DOM elements (I’m not sure if I’ve ever gotten confirmation if this was just coincidence of if they rushed to get it in after news of jQuery’s release spread – I’m betting it was just coincidence).

A few months later I wrote a blog post comparing the various state-of-the-art solutions comparing the syntax required to bind an event to multiple elements:
John Resig - Event Selector Showdown

This video is processing – it'll appear automatically when it's done.

Sorry, we couldn't find where this annotation belongs on the page. But you can read it here:

This is the point on which plugins could be attached to jQuery. This eventually became just a reference to $.prototype, which makes a lot more sense. I had $.fn in from day one so that people could write extensions to jQuery, adding in their own methods. As it turns out this ended up being wildly successful.

The first jQuery plugin was created by Michael Geary on January 25th, just 11 days after the first release of the library (even before this particular version of the file!):
JSON for jQuery | mg.to

More details about the release here:
John Resig - First jQuery Plugin

This video is processing – it'll appear automatically when it's done.

Sorry, we couldn't find where this annotation belongs on the page. But you can read it here:

You should probably be scratching your head if you’re familiar with CSS. This is actually my meager attempt at mapping some common XPath selectors to CSS! I wrote a whole blog post about this back in 2005, when I was experimenting with this concept:
John Resig - XPath and CSS Selectors

I really liked XPath selectors (they were much more powerful than the then-currently-available CSS selectors) and used them a bunch in my day-to-day coding. In retrospect focusing on CSS was a much better idea as it was more understandable to a wider audience. I believe the XPath selectors were removed by the 1.0 release – I was probably the only person who used them.

This video is processing – it'll appear automatically when it's done.

Sorry, we couldn't find where this annotation belongs on the page. But you can read it here:

I’m kind of amazed that CSS still doesn’t have some equivalent to these selectors – they’re so useful! Selecting inputs by type, or all inputs in aggregate, is such a common operation. Glad we had these built in but it’d be ideal to be able to handle these natively!

This video is processing – it'll appear automatically when it's done.

Sorry, we couldn't find where this annotation belongs on the page. But you can read it here:

Oofka! These Regexes are pretty gnarly… I’m sorry!

This video is processing – it'll appear automatically when it's done.

Sorry, we couldn't find where this annotation belongs on the page. But you can read it here:

Not sure why I was doing .constructor == String. Doing: typeof foo == “string” makes more sense and seems less error prone.

This video is processing – it'll appear automatically when it's done.

Sorry, we couldn't find where this annotation belongs on the page. But you can read it here:

Re-declaration of variables! Stuff like this went away once I started passing the code through JSLint. I think that was before the 1.0 release, as well.

This video is processing – it'll appear automatically when it's done.

Sorry, we couldn't find where this annotation belongs on the page. But you can read it here:

I just want to note how few comments there are in the original jQuery source. It’s really quite dramatic. Thankfully this is something that was improved upon over time!

That being said I am proud of the fact that jQuery had really good documentation from day 1:
jQuery: Documentation: Overview

This may not seem that surprising but at the time of its release jQuery was pretty much the only JavaScript library with documentation! I distinctly remember when PrototypeJS finally got some (community-created) documentation in January 2007 (a year after jQuery’s release). jQuery had a year-long head-start on documentation!

It bothered me that so few JavaScript libraries had documentation when I was making jQuery and I made a point to write online docs from the get-go. I’m glad I did!

I’m frequently surprised by how few developers will put in the (marginal) extra effort to document their code. So many more people will be able to use and understand if you do!

This video is processing – it'll appear automatically when it's done.

Sorry, we couldn't find where this annotation belongs on the page. But you can read it here:

You’ll notice that I loved single letter variable names. This was a hard habit to break – but I eventually did! Especially when other developers started to use this code and contribute to it.

This video is processing – it'll appear automatically when it's done.

Sorry, we couldn't find where this annotation belongs on the page. But you can read it here:

I noticed that I used new Array() and new RegExp() in the code – but I’m not entirely sure why! Why not just use [] and //?

This video is processing – it'll appear automatically when it's done.

Sorry, we couldn't find where this annotation belongs on the page. But you can read it here:

In 2005 there wasn’t a good, standard, way for easily attaching events to DOM elements. Some libraries had this built in, like Prototype, Dojo, and MochiKit, but if you wanted a library that did nothing but that one didn’t really exist! PPK organized a contest to try and find a definitive solution to this problem:

undefined Quirksmode
My recent entry addEvent() considered harmful generated many interesting comments and technical pointers. It's clear that the original addEvent() function doesn't quite cut the cake any more, and it's equally clear that we badly need a function such as this to keep our scripts simple.

As you can see from the comments I submitted one of the first solutions:
John Resig - Flexible Javascript Events

…and you can see here that I won the contest!
... and the winner is ... - QuirksBlog

As you can see by the comments there, my winning submission was rather… contentious.

I agreed with a lot of the discussion that happened and eventually fell in love with Dean Edwards' solution to this problem (he was one of the judges on the contest!):
addEvent() - My Solution
addEvent() - Follow Up

It’s his code, modified by me, that we eventually see integrated into jQuery as the core addEvent/removeEvent mechanism.

This video is processing – it'll appear automatically when it's done.

Sorry, we couldn't find where this annotation belongs on the page. But you can read it here:

why not elements.events = elements.events || {} ?

This video is processing – it'll appear automatically when it's done.

Sorry, we couldn't find where this annotation belongs on the page. But you can read it here:

Never was moved to a module! Still exists in jQuery to this day :)

This video is processing – it'll appear automatically when it's done.

Sorry, we couldn't find where this annotation belongs on the page. But you can read it here:

Haha – this was to protect against people including Prototype and jQuery in the page in the wrong order. I definitely remember this being a big enough problem that it warranted this check… unfortunately.

This video is processing – it'll appear automatically when it's done.

X

Integrate the suggestion into the annotation, keeping the contributor guidelines in mind.

Correct this Line Edit Video Id
Add an Image Formatting Help
  • Add an image, video, or tweet by pasting in the URL:

    http://genius.com/logo.png
  • Add a link like this:

    [Check out my fave website](http://genius.com)
  • Simple formatting:

    *Italicize Album Titles*
    > This is how you quote from other sources

How to write for Genius